﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using MMessaging.Test.Fahrstuhl.Engine;
using MMessaging.Test.Fahrstuhl.ViewModels;
using System.ComponentModel;
using TUtils.Extensions;

namespace MMessaging.Test.Fahrstuhl.Views
{
	/// <summary>
	/// Interaction logic for MainWindow.xaml
	/// </summary>
	public partial class ElevatorView : Window
	{
		partial void OnConstructed()
		{
			InitializeComponent();
			if (TWPFHelper.IsInDesignMode)
				Model = new ElevatorViewModel(null,new Thickness(0,0,0,0));
		}

		protected override void OnInitialized(EventArgs e)
		{
			base.OnInitialized(e);
			DataContext = this;
			Model = new ElevatorViewModel(ElevatorEngine.ElevatorEngine.Instance.Switch, new Thickness(0, 0, 0, 0));

		}

		private void bttnLevel2Down_Click(object sender, RoutedEventArgs e)
		{
			Model.SetNewButtonState(
				new ButtonStateOutsideCabin(
					floorNo: 2,
					pressed: true,
					upDown: UpDownEnum.Down));
		}

		private void bttnLevel1Up_Click(object sender, RoutedEventArgs e)
		{
			Model.SetNewButtonState(
				new ButtonStateOutsideCabin(
					floorNo: 1,
					pressed: true,
					upDown: UpDownEnum.Up));
		}

		private void bttnLevel1Down_Click(object sender, RoutedEventArgs e)
		{
			Model.SetNewButtonState(
				new ButtonStateOutsideCabin(
					floorNo: 1,
					pressed: true,
					upDown: UpDownEnum.Down));
		}

		private void bttnLevel0Up_Click(object sender, RoutedEventArgs e)
		{
			Model.SetNewButtonState(
				new ButtonStateOutsideCabin(
					floorNo: 0,
					pressed: true,
					upDown: UpDownEnum.Up));

		}

		private void bttnInside0_Click(object sender, RoutedEventArgs e)
		{
			Model.SetNewButtonState(
				new ButtonStateInsideCabinWantFloor(
					toFloorNo: FloorEnum.Floor_0,
					pressed: true));
		}

		private void bttnInside1_Click(object sender, RoutedEventArgs e)
		{
			Model.SetNewButtonState(
				new ButtonStateInsideCabinWantFloor(
					toFloorNo: FloorEnum.Floor_1,
					pressed: true));
		}

		private void bttnInside2_Click(object sender, RoutedEventArgs e)
		{
			Model.SetNewButtonState(
				new ButtonStateInsideCabinWantFloor(
					toFloorNo: FloorEnum.Floor_2,
					pressed: true));
		}
	}
}
